package com.bckj.fastboot.iot.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bckj.fastboot.iot.common.dto.query.IotProtocolQuery;
import com.bckj.fastboot.iot.common.dto.response.IotProtocolResponse;
import com.bckj.fastboot.iot.common.entity.IotProtocol;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

/**
 * IotProtocolMapper
 *
 * @author wfc
 * @date 2025/9/25 11:18
 **/
@Mapper
public interface IotProtocolMapper extends BaseMapper<IotProtocol> {

    @SelectProvider(type = IotProtocolProvider.class, method = "findList")
    List<IotProtocolResponse> findList(IotProtocolQuery query);

    @SelectProvider(type = IotProtocolProvider.class, method = "findById")
    IotProtocolResponse findById(Long id);

    class IotProtocolProvider {

        public String findList(IotProtocolQuery query) {
            SQL sql = new SQL();
            sql.SELECT("ip.*");
            sql.FROM("iot_protocol ip");
            listWhere(sql, query);
            return sql.toString();
        }

        private void listWhere(SQL sql, IotProtocolQuery query) {

        }

        public String findById(Long id) {
            SQL sql = new SQL();
            return sql.toString();
        }
    }
}
